package han.study.bean;


import java.sql.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Customer {
    private int id;
    private String name;
    private String email;
    private Date birth;

    public Customer() {
    }

    public Customer(int id, String name, String email, Date birth) {
        this.id = id;
        this.name = name;
        this.email = email;
        this.birth = birth;
    }

    public Customer(int id, String name, String email, String birth) throws ParseException {
        this.id = id;
        this.name = name;
        this.email = email;
        java.util.Date date = new java.util.Date();
        SimpleDateFormat simpleDateFormat =(SimpleDateFormat) DateFormat.getDateInstance();
        simpleDateFormat.applyPattern("yyyy-MM-dd");
        date = simpleDateFormat.parse(birth);
        java.sql.Date realBirth =new java.sql.Date(date.getTime());
        this.birth = realBirth;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getBirthday() {
        return birth;
    }

    public void setBirthday(Date birth) {
        this.birth = birth;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", birth=" + birth +
                '}';
    }
}
